package cn.itsource.config;


import cn.dev33.satoken.jwt.StpLogicJwtForStateless;
import cn.dev33.satoken.stp.StpLogic;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@Configuration
@Import(RedisConfig.class) //把redisConfig交给spring管理
// @AutoConfigureBefore(RedisConfig.class)
public class AuthAutoConfiguration {
    // Sa-Token 整合 jwt (Stateless 无状态模式)
    @Bean
    public StpLogic getStpLogicJwt() {
        return new StpLogicJwtForStateless();
    }
    @Bean
    public SaTokenConfigure getSaTokenConfigure() { //交给spring管理
        return new SaTokenConfigure();
    }
    @Bean
    public StpInterfaceImpl getStpInterfaceImpl() { //交给spring管理
        return new StpInterfaceImpl();
    }

    @Bean
    public TokenInterceptor getTokenInterceptor() {
        return new TokenInterceptor();
    }

    // PasswordEncoder 是Spring Security中的一个加密方法
    //定义成bean
    @Bean
    public PasswordEncoder passwordEncoder(){
        return new BCryptPasswordEncoder();
    }

}